<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
            overflow: auto;
        }
    </style>
</head>
<body>
    <div>我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容</div>
    <script>
        //scrollWidth及Height返回内容的实际高度和宽度
        //scrollTop和scrollLeft返回被卷去的顶部及左部距离
        var div =document.querySelector('div');
        div.addEventListener('scroll',function(){
            console.log(parseInt(this.scrollTop));
        })
    </script>
</body>
</html>